define(["dojo/_base/declare", "dijit/form/Form", "dijit/form/TextBox", "dijit/form/NumberTextBox", "dijit/form/Button", "dojo/data/ItemFileWriteStore"], function(declare){
    declare("my.form.AddStudentDegreeForm", [dijit.form.Form], {
    		startup : function(){
    			dijit.byId("degreeIdStudent").attr("disabled", true); 
    			dojo.xhrPost(
    				    {
    				        url : "getCurrentUserAction.action",
    				        handleAs : "json",
    				        load : dojo.hitch(this, this.onLoadCurrentUser),
    				    });
    		},
    		
    		onLoadCurrentUser : function(responseObject, ioArgs){
    			var classesStore = new dojo.data.ItemFileWriteStore(
    		    	    {
    		    	    	url:'getTeacherClassesAction.action?teacher.id='+responseObject.user.id,
    		 			    requestMethod : "post"
    		    	    });
    			
    			var classesDropDown = dijit.byId("degreeIdClasses");
    			classesDropDown.set("store",classesStore);
    			
    			dojo.connect(classesDropDown, "onChange", this, function(){
    				var classesDropDown = dijit.byId("degreeIdClasses");
    				var studentStore = new dojo.data.ItemFileWriteStore(
        		    	    {
        		    	    	url:'getStudentsInClassesAction.action?classes.id='+classesDropDown.get("value"),
        		 			    requestMethod : "post"
        		    	    });
    				var studentsDropDown = dijit.byId("degreeIdStudent");
    				studentsDropDown.set("disabled", false);
    				studentsDropDown.reset();
    				studentsDropDown.set("store",studentStore);
    			});
    			
    		},
    		
    		onSubmit : function(){
    			return this.isValid() && dijit.byId("degreevalue").isValid() && dijit.byId("degreeIdClasses").isValid()
    				&& dijit.byId("degreeIdStudent").isValid()
    				&& dijit.byId("addGradeStudent").isValid()
    				&& dijit.byId("addGradeDesc").isValid();
    		}

    		
    		
    });
});